﻿@model IEnumerable<SCMS.UI.Models.ViewTenders>
@{
    ViewBag.Title = "ViewTenders";
}
<div class="partialViewCard">
    <div class="partialViewCardHeader">
        <h3>
            Tender Analysis</h3>
    </div>
    <br />
    @if (Model.Count() > 0)
    {
        <div id="tablewrapper">
            <div id="tableheader">
                <div class="search">
                    <b>Search By:</b><br />
                    <select id="columns" onchange="sorter.search('query')"></select>
                    <input type="text" id="query" onkeyup="sorter.search('query')" />
                </div>
                <span class="details">
                    <div>Records <span id="startrecord"></span>-<span id="endrecord"></span> of <span id="totalrecords"></span></div>
                </span>
            </div>
            <br /><br /><br />
            <table width="98%" align="center" cellpadding="0" cellspacing="0" border="0" id="table" class="tinytable">
                <thead>
                    <tr>
                        <th><h3>TA Ref No.</h3></th><th><h3>OR Ref No.</h3></th><th><h3>Prepared By</h3></th>
                        <th><h3>Status</h3></th><th><h3>Status Date</h3></th>                       
                    </tr>
                </thead>
                <tbody>
                    @foreach (var item in Model)
                    {
                        <tr onclick="sendRequest('/TenderAnalysis/ViewTenderDetails/@item.EntityTenderAnalysis.Id', 'tenderDiv', 'loading')" style=" cursor:pointer;">
                            <td>
                                @item.EntityTenderAnalysis.RefNumber
                            </td>
                            <td>
                                @item.EntityTenderAnalysis.OrderRequest.RefNumber
                            </td>
                            <td>
                                @item.EntityTenderAnalysis.Staff1.Person.FirstName 
                                &nbsp;
                                @item.EntityTenderAnalysis.Staff1.Person.OtherNames
                            </td>
                            <td align="center">
                                @if (item.EntityTenderAnalysis.IsAuthorized == true)
                                { 
                                    <b style="color: Green; font-weight: bold;">
                                        AU
                                    </b>
                                }
                                else if (item.EntityTenderAnalysis.IsRejected == true)
                                {
                                    <b style="color: Red; font-weight: bold;">
                                        RJ
                                    </b>
                                }
                                else if (item.EntityTenderAnalysis.IsSubmitted == true)
                                { 
                                    @Html.Raw("CR")
                                }
                                else
                                { 
                                    @Html.Raw("NEW")
                                }
                            </td>
                            <td align="center">
                                @if (item.EntityTenderAnalysis.IsAuthorized == true)
                                { 
                                    @item.EntityTenderAnalysis.AuthorizedOn.Value.ToString("dd/MM/yyyy")
                                }
                                else if (item.EntityTenderAnalysis.IsRejected)
                                {
                                    if (item.EntityTenderAnalysis.AuthorizedOn.HasValue)
                                    { 
                                        @item.EntityTenderAnalysis.AuthorizedOn.Value.ToString("dd/MM/yyyy")
                                    }
                                }
                                else if (item.EntityTenderAnalysis.IsSubmitted == true)
                                { 
                                    @item.EntityTenderAnalysis.PreparedOn.Value.ToString("dd/MM/yyyy")
                                }
                                else
                                { 
                                    @item.EntityTenderAnalysis.PreparedOn.Value.ToString("dd/MM/yyyy")
                                }
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
            <div id="tablefooter">
                <div id="tablenav">
                    <div>
                        <img src="../../Content/images/pager/first.gif" width="16" height="16" alt="First Page" onclick="sorter.move(-1,true)" />
                        <img src="../../Content/images/pager/previous.gif" width="16" height="16" alt="Previous Page" onclick="sorter.move(-1)" />
                        <img src="../../Content/images/pager/next.gif" width="16" height="16" alt="Next Page" onclick="sorter.move(1)" />
                        <img src="../../Content/images/pager/last.gif" width="16" height="16" alt="Last Page" onclick="sorter.move(1,true)" />
                    </div>
                    <div>
                        <select id="pagedropdown"></select>
                    </div>
                    <div>
                        <a href="javascript:sorter.showall()">view all</a>
                    </div>
                </div>
                <div id="tablelocation">
                    <div>
                        <select onchange="sorter.size(this.value)">
                        <option value="5">5</option>
                            <option value="10" selected="selected">10</option>
                            <option value="20">20</option>
                            <option value="50">50</option>
                            <option value="100">100</option>
                        </select>
                        <span>Entries Per Page</span>
                    </div>
                    <div class="page">Page <span id="currentpage"></span> of <span id="totalpages"></span></div>
                </div>
            </div>
        </div>
        
    }
    @if (Model.Count() < 1)
    {
        <i style="text-align: center;">No Tender Analyses prepared.</i>
    }
    <br />
</div>